var con = require('../../../utils/data.js');
var WxParse = require("../../../wxParse/wxParse.js");
var QQMapWX = require('../../../utils/qqmap-wx-jssdk.min.js');
var app = getApp();
var lng, lat, name, address;

Page({
  data: {
    longitude: {},
    latitude: {},
    markers: [],

  },
  onLoad: function () {
    var that = this; 
    var oneRequest = {
      "status": "1", "info": {
        "id": "3", "wxappid": "6", "name": "室内装饰材料经营部", "tel": "13882055662", "address": "四川省成都市双流区白家镇川大南路208号临江丽苑-三期", "longitude": "104.030180", "latitude": "30.542930", "intro": "<p>本人诚信经营，近二十年的装修经营，对装修过程中的各种材料、装修套路非常清楚。对装修有想了解咨询的欢迎来电，对各种装修材料有需求的欢迎来电，需要各种高大上的门欢迎来电咨询，醪糟一绝为本人自家酿制，味道巴适，用材健康安全，可放心购买食用。</p>" } };

    name = oneRequest.info.name;
    address = oneRequest.info.address;
    WxParse.wxParse('shoperIn', 'html', oneRequest.info.intro, that, 0)
    that.setData({
      address: oneRequest.info.address,
      name: oneRequest.info.name,
      tel: oneRequest.info.tel 
    })


    var demo = new QQMapWX({
      key: 'QCDBZ-GZ3WI-BQDG7-5H24V-Y2HSO-I7BSG'
    });
    
    var twoRequest = { "lng": "104.030180", "lat": "30.542930" };


    lng = twoRequest.lng;
    lat = twoRequest.lat;
    that.setData({
      longitude: twoRequest.lng,
      latitude: twoRequest.lat,
      markers: [{
        longitude: twoRequest.lng,
        latitude: twoRequest.lat,
        iconPath: '../../../images/map/map.png',
        title: name,
        address: address,
        alpha: 1,
        width: 40,
        height: 40
      }],
    });


  },
  bookTap: function () {
    wx.makePhoneCall({
      phoneNumber: '13882055662',
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    })
  },
  onShareAppMessage: function (res) {

    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: this.data.DefaultData.details.details_subject,
      path: 'pages/decor/map/map',
      success: function (res) {
        // 转发成功
        console.log("转发已经成功");
      },
      fail: function (res) {
        console.log("转发已经失败");
      }
    }
  },
  bindgothere: function (e) {
  
    wx.openLocation({
      latitude: parseFloat(this.data.latitude),
      longitude: parseFloat(this.data.longitude),
      name: this.data.name,
      address: this.data.address
    })
  }
});




